// 8. Loading框，通过showDialog+AlertDialog实现
import 'package:baseProjectFlutter/config/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

Future showLoadingDialog({String msg = 'loading...', bool clickMaskDismiss = true}) {
  return SmartDialog.showLoading(msg: msg, clickMaskDismiss: clickMaskDismiss);
}
//隐藏 loading
Future hideLoadingDialog() {
  return SmartDialog.dismiss(status: SmartStatus.loading);
}

class LoadingDialog {
  static Widget dialog({
    String msg = 'loading...',
  }) {
    return Container(
      width: 120,
      height: 120,
      alignment: Alignment.center,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          const SizedBox(
            width: 46,
            height: 46,
            child: CircularProgressIndicator(
              valueColor: AlwaysStoppedAnimation(AppColors.load_and_retry_circle_color),
              strokeWidth: 2,
            ),
          ),
          const SizedBox(
            height: 10,
          ),
          Offstage(
            offstage: false,
            child: Text(
              msg,
              style: const TextStyle(color: AppColors.load_and_retry_load_title_color, fontSize: 12),
            ),
          )
        ],
      ),
    );
  }
}
